package com.sxdz.config

import org.springframework.cache.ehcache.EhCacheFactoryBean
import org.springframework.cache.ehcache.EhCacheManagerFactoryBean
import org.springframework.context.annotation.Bean
import org.springframework.context.annotation.Configuration
import org.springframework.core.io.ClassPathResource

/**
 * Created by zb on 2015/6/11.
 */

@Configuration
class CacheConfig {

    @Bean
    EhCacheManagerFactoryBean ehCacheManagerFactoryBean(){
        new EhCacheManagerFactoryBean (
                configLocation: new ClassPathResource ("ehcache-config.xml"),
                shared: true
        )
    }


    @Bean
    EhCacheFactoryBean tokenCache(EhCacheManagerFactoryBean bean){
        new EhCacheFactoryBean(
                cacheManager:bean.object,
                cacheName:"activeTokenCache"
        )
    }
}
